using System;
using Science.Mathematics;
using M = Science.Mathematics.Calculus;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter30
{
	/// <summary>
	/// Example03: Magnetic Field on the Axis of a Circular Current Loop
	/// Consider a circular wire loop of radius R located in the 
	/// yz plane and carrying a steady current I, as in Figure 
	/// 30.6. Calculate the magnetic field at an axial point P 
	/// a distance x from the center of the loop.
	/// </summary>
	public class Example03
	{
		public Example03()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.MagneticField B = new L.MagneticField();
			
			L.Line.Parameterization fa = new L.Line.Parameterization(Line);
			L.Line l = new L.Line(fa);
			l.ParameterStartValue = 0.0;
			l.ParameterEndValue = 2.0*Math.PI;
		
			L.ElectricCurrent I = new L.ElectricCurrent();
			I.A = 10.0;

			L.Position x = new L.Position();
			x.X = 1.0;
			x.Y = 0.0;
			x.Z = 0.0;
			
			B.BiotSavartLaw(I,l,x);

			result+=Convert.ToString(B.X)+"\r\n"
				+Convert.ToString(B.Y)+"\r\n"
				+Convert.ToString(B.Z)+"\r\n";

			result+=Convert.ToString(L.Constant.
				PermeabilityOfFreeSpace*I.A*1.0*1.0/2.0
				/Math.Pow(x.X*x.X+1.0*1.0,1.5))+"\r\n";
		}
		private L.Position Line(double t)
		{
			L.Position xyz = new L.Position();
			xyz.X = 0.0;
			xyz.Y = Math.Cos(t);
			xyz.Z = Math.Sin(t);
			return xyz;
		}
	}
}
